<?php 


require_once '../config.php';
require_once '../functions.php';

$sentence = book_fetch_all('select * from sentence');



?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/static/assets/css/sentence.css">
    <link rel="stylesheet" href="/static/assets/css/base.css">
    <script src="/static/assets/vendors/jquery/jquery.min.js"></script>
</head>

<body>
    <div class="sentence">
        <div class="sentence_head">
            <img src="/static/assets/img/sentence/h1.jpg" alt="" id="im">
        </div>
        <div class="sentence_top">
            <ul>
                <?php foreach($sentence as $item):?>
                    <li>
                    <div class="sentence_img">
                        <img src="<?php echo $item['picture']?>" alt="">
                    </div>
                    <div class="sentence_txt">
                        <h1>《<?php echo $item['title']?>》</h1>
                        <p> <?php echo $item['content']?> </p>
                        <span>———— <?php echo $item['name']?></span>
                        <div class="love">
                            <p id="<?php echo $item['id']?>"  class="icomoon_icon icon-tongue " onclick="add('<?php echo $item['id']?>','<?php echo $item['number']?>')"> <?php echo $item['number']?> 赞</p>
                            <p class="icomoon_icon icon-file-text2" onclick="love('<?php echo $item[id]?>')"></p>
                        </div>
                    </div>
                </li>
                <?php endforeach?>   
            </ul>
        </div>
        
    </div>

</body>




<script>
    function tup(num1) {
        var sen = document.getElementsByClassName('sentence_head')[0];
        var im = document.getElementById('im');
        var i = 1
        sen.onclick = function () {
            if (i <= num1) {
                im.src = "/static/assets/img/sentence/h" + i + ".jpg";
                i++;
            } else {
                i = 1;
                im.src = "/static/assets/img/sentence/h" + i + ".jpg";
            }

        }
    };
    tup(6);
</script>
<script>
function add(id,number){
     var num= parseInt(number)+1;
     var k = document.getElementById(id).innerHTML=" "+num+" 赞";
     console.log(k)
     $.get('/admin/api/number.php',{ num1: num,id:id },function(res){
    })
 }
function love(id){
     
     $.get('/admin/api/number.php',{id:id },function(res){
    })
 }



 

</script>

</html>